#!/bin/bash

# while-menu-dialog: a menu driven system information program

DIALOG_CANCEL=1
DIALOG_ESC=255
HEIGHT=0
WIDTH=0

display_result() {
  dialog --title "$1" \
    --no-collapse \
    --msgbox "$result" 0 0
}

while true; do
  exec 3>&1
  selection=$(dialog \
    --backtitle "Debian installer v1.1" \
    --title "Menu" \
    --clear \
    --cancel-label "Exit" \
    --menu "Please select:" $HEIGHT $WIDTH 4 \
    "1" "Inspect" \
    "2" "Update" \
    "3" "Install" \
    2>&1 1>&3)
  exit_status=$?
  exec 3>&-
  case $exit_status in
    $DIALOG_CANCEL)
      clear
      echo "Program terminated."
      exit
      ;;
    $DIALOG_ESC)
      clear
      echo "Program aborted." >&2
      exit 1
      ;;
  esac
  case $selection in
    1 )
      vim debian
      ;;
    2 )
      sudo apt update
      sudo apt upgrade
      ;;
    3 )
      sudo apt install abiword abook acpi alsa-tools alsa-utils arc-theme bash-completion bc btop calcurse cargo cmus curl dunst dvtm ethtool feh firefox-esr flashrom fonts-jetbrains-mono galculator gh gnumeric gufw htop hw-probe inxi jgmenu lxappearance lxappearance-obconf minitube mpv neofetch nextcloud-desktop nextcloud-desktop-cmd obconf openbox papirus-icon-theme pcmanfm picom pulseaudio python3-pip ranger redshift redshift-gtk rofi rust-all scribus scrot slim smartmontools sxhkd thunderbird tint2 tlp tlp-rdw transset udiskie ueberzug ufw unzip usbutils vifm vim wget xdg-user-dirs xdg-user-dirs-gtk xdg-utils xinit xorg xserver-xorg-input-synaptics xterm yubioath-desktop zathura-pdf-poppler
      ;;
  esac
done
